import 'package:flutter/material.dart';
import 'package:fsuper/fsuper.dart';

class MyCheckBox extends StatefulWidget {
  bool isCheck;
  String desc;
  Function onChange;

  MyCheckBox(this.desc, this.isCheck, this.onChange);

  @override
  _MyCheckBoxState createState() => _MyCheckBoxState();
}

class _MyCheckBoxState extends State<MyCheckBox> {
  @override
  Widget build(BuildContext context) {
    return FSuper(
        width: 84,
        height: 32,
        text: widget.desc,
        textSize: 12,
        textAlignment: Alignment.centerLeft,
        padding: EdgeInsets.only(left: 24),
        child1: widget.isCheck
            ? Icon(Icons.check_box, color: Theme.of(context).accentColor)
            : Icon(Icons.check_box_outline_blank, color: Colors.grey),
        child1Alignment: Alignment.centerLeft,
        onClick: () {
          widget.isCheck = !widget.isCheck;
          setState(() {});
          widget.onChange(widget.isCheck);
        });
  }
}
